/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.lang.reflect.Field;

/**
 * <p>Project: jse2303 - Reflect01</p>
 * <p>Powered by webrx On 2023-07-28 11:02:27</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Reflect02 {
    public static void main(String[] args) throws Exception {
        Class<Apple> c = Apple.class;

        //反射获取属性对象Field
        //Field price = c.getDeclaredField("price");
        //System.out.println(price);

        //获取所有类声明的属性
        //c.getDeclaredFields()
        //c.getDeclaredField(String name)

        //获取public属性
        //c.getFields()
        //c.getField(String name)

        //Field address = c.getField("address");
        //System.out.println(address);

        Field[] fs = c.getDeclaredFields();
        for (Field f : fs) {
            //System.out.println(f);
            System.out.println(f.getModifiers()); //0没有 1public 2private 4proteced
            System.out.println(f.getName());
            //System.out.println(f.getGenericType());
            //System.out.println(f.getType());


        }


    }
}
